package com.sunzn.media.library.anim;

import android.content.Context;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

import com.sunzn.media.library.R;

public class AnimationHelper {

    public interface AnimationListener {

        void onAnimationStart(Animation animation);


        void onAnimationEnd(Animation animation);

        void onAnimationRepeat(Animation animation);
    }


    public static void startIntoAnim(Context context, View view, View close, View arrow) {
        Animation animation = AnimationUtils.loadAnimation(context, R.anim.anim_into_from_btm_to_top);
        Animation animation1 = AnimationUtils.loadAnimation(context, R.anim.anim_quit_from_one_to_zero);
        Animation animation2 = AnimationUtils.loadAnimation(context, R.anim.anim_spin_from_down_to_up);
        view.setVisibility(View.VISIBLE);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                close.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        view.startAnimation(animation);
        close.startAnimation(animation1);
        arrow.startAnimation(animation2);
    }

    public static void startQuitAnim(Context context, View view, View close, View arrow) {
        Animation animation = AnimationUtils.loadAnimation(context, R.anim.anim_quit_from_top_to_btm);
        Animation animation1 = AnimationUtils.loadAnimation(context, R.anim.anim_into_from_zero_to_one);
        Animation animation2 = AnimationUtils.loadAnimation(context, R.anim.anim_spin_from_up_to_down);
        close.setVisibility(View.VISIBLE);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                view.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        view.startAnimation(animation);
        close.startAnimation(animation1);
        arrow.startAnimation(animation2);
    }

}
